package com.polaris.live.ui.party.widget.videoseat

import android.content.Context
import android.util.AttributeSet
import android.view.LayoutInflater
import android.view.View
import com.polaris.live.databinding.WidgetVideoSeatBinding
import com.polaris.live.resp.back_resp.UserRoomThemeResp
import com.polaris.live.ui.party.widget.videoseat.base.BaseVideoSeatItemView
import com.polaris.live.ui.party.widget.videoseat.base.BaseVideoSeatView

/**
 * VideoSeatView
 * @author Created by 天晴 on 2024/6/21 17:00
 * @since 1.0.0
 **/
class VideoSeatView(context: Context, attrs: AttributeSet?) : BaseVideoSeatView<VideoSeatItemView>(context, attrs) {

    val mBinding = WidgetVideoSeatBinding.inflate(LayoutInflater.from(context), this)

    init {
        initView()
    }

    override fun getSeatCount() = 9

    override fun createView(seatId: Int): VideoSeatItemView {
        return when (seatId) {
            0 -> mBinding.seat1
            1 -> mBinding.seat2
            2 -> mBinding.seat3
            3 -> mBinding.seat4
            4 -> mBinding.seat5
            5 -> mBinding.seat6
            6 -> mBinding.seat7
            7 -> mBinding.seat8
            8 -> mBinding.seat9
            else -> throw Exception("no SeatItemView")
        }
    }

    fun setTheme(userRoomTheme: UserRoomThemeResp? = null) {
        val viewList = getSeatViewAddr()
        viewList.forEach {
            val view = it.second
            if (view is BaseVideoSeatItemView) {
                view.upDateSkinView(userRoomTheme)
            }
        }
    }

    private fun getSeatViewAddr(): List<Pair<String, View>> {
        return listOf(
            Pair("0", mBinding.seat1),
            Pair("1", mBinding.seat2),
            Pair("2", mBinding.seat3),
            Pair("3", mBinding.seat4),
            Pair("4", mBinding.seat5),
            Pair("5", mBinding.seat6),
            Pair("6", mBinding.seat7),
            Pair("7", mBinding.seat8),
            Pair("8", mBinding.seat9)
        )
    }

}